package com.whately.core.base.constant;

import lombok.Getter;

/**
 * 短信模板
 */
public enum WhatelyCoreSmsEnum {

    //注册
    register("您正在申请手机注册，验证码为：{}，{}分钟内有效。如非本人操作，请忽略本短信。",3),

    //登录
    login("{}为您的登录验证码，请于{}分钟内填写，如非本人操作，请忽略本短信。",3),

    //变更登录手机
    change_mobile("你正在变更登录手机号，验证码是{}，请于{}分钟内填写。如非本人操作，请忽略本短信。",3),

    //找回密码
    forget_pwd("您的动态验证码为：{}，您正在进行密码重置操作，请于{}分钟内填写。如非本人操作，请忽略本短信！",3),
    ;

    @Getter
    String content;
    @Getter
    int expireMinutes;

    private WhatelyCoreSmsEnum(String content,int expireMinutes) {
        this.content = content;
        this.expireMinutes = expireMinutes;
    }


    public static WhatelyCoreSmsEnum getSmsByVerifyCodeType(VerifyCodeTypeEnum codeTypeEnum) {
        if(codeTypeEnum==null){
            return null;
        }
        //注册短信
        if(codeTypeEnum==VerifyCodeTypeEnum.corp_register||codeTypeEnum==VerifyCodeTypeEnum.user_register){
            return WhatelyCoreSmsEnum.register;
        }else if(codeTypeEnum==VerifyCodeTypeEnum.corp_mobile_login||codeTypeEnum==VerifyCodeTypeEnum.corp_pwd_login
        ||codeTypeEnum==VerifyCodeTypeEnum.user_mobile_login||codeTypeEnum==VerifyCodeTypeEnum.user_pwd_login||codeTypeEnum==VerifyCodeTypeEnum.pfuser_pwd_login){
            return WhatelyCoreSmsEnum.login;
        }else if(codeTypeEnum==VerifyCodeTypeEnum.change_mobile) {
            return WhatelyCoreSmsEnum.change_mobile;
        }else if(codeTypeEnum==VerifyCodeTypeEnum.forget_pwd_find_by_mobile) {
            return WhatelyCoreSmsEnum.forget_pwd;
        }


        return null;
    }

    public static boolean openWhrsSmsChannel(VerifyCodeTypeEnum codeTypeEnum){
        if(codeTypeEnum==VerifyCodeTypeEnum.corp_mobile_login||codeTypeEnum==VerifyCodeTypeEnum.corp_pwd_login
                ||codeTypeEnum==VerifyCodeTypeEnum.user_mobile_login||codeTypeEnum==VerifyCodeTypeEnum.user_pwd_login||codeTypeEnum==VerifyCodeTypeEnum.pfuser_pwd_login){
            return true;
        }
        return false;
    }
}
